﻿using System.Collections.Generic;
using ManagerClient.Messaging.Logic;

namespace ManagerClient.Manage.Logic
{
    public class MailControlViewModel : TabPageViewModelBase
    {
        private readonly IncomingMailViewModel incomingMailViewModel;
        private readonly SendMailViewModel sendMailViewModel;
        private string selectedMessageType;
        private ViewModelBase selectedViewModel;

        public MailControlViewModel(SendMailViewModel sendMailViewModel, IncomingMailViewModel incomingMailViewModel)
        {
            Title = "Почта";
            this.sendMailViewModel = sendMailViewModel;
            this.incomingMailViewModel = incomingMailViewModel;
            SelectedViewModel = incomingMailViewModel;
            SelectedMessageType = "Входящие";
        }


        public ViewModelBase SelectedViewModel
        {
            get { return selectedViewModel; }
            private set
            {
                selectedViewModel = value;
                RaisePropertyChanged(() => SelectedViewModel);
            }
        }

        public IEnumerable<string> MessagesTypes
        {
            get { return new[] {"Входящие", "Исходящие"}; }
        }


        public string SelectedMessageType
        {
            get { return selectedMessageType; }
            set
            {
                selectedMessageType = value;
                RaisePropertyChanged(() => SelectedMessageType);
                if (SelectedMessageType == "Входящие")
                {
                    SelectedViewModel = incomingMailViewModel;
                }
                else if (SelectedMessageType == "Исходящие")
                {
                    SelectedViewModel = sendMailViewModel;
                }
            }
        }
    }
}